package com.sanalkitaplik.usermanagement;
import javax.faces.event.ValueChangeEvent;

public class UserRegistration {
	
	private String userName;
	private String password;
	private String passwordCheck;
	private String emailAccountName;
	private String emailHostAddress;
	private String emailAccountNameCheck;
	private String firstName;
	private String lastName;
	private UserRoleRegistration userRole;
	private int roleCode;
	
	public UserRegistration() {
		this.userName = "";
		this.password = "";
		this.passwordCheck = "";
		this.emailAccountName = "";
		this.emailHostAddress = "";
		this.firstName = "";
		this.lastName = "";
		this.userRole = new StudentRegistration();
		this.roleCode = 0;
	}
	
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	public String getUserName() {
		return this.userName;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getPassword() {
		return this.password;
	}
	
	public void setPasswordCheck(String passwordCheck) {
		this.passwordCheck = passwordCheck;
	}
	
	public String getPasswordCheck() {
		return this.passwordCheck;
	}
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public void setEmailAccountName(String emailAccountName) {
		this.emailAccountName = emailAccountName;
	}
	
	public String getEmailAccountName() {
		return this.emailAccountName;
	}
	
	public void setEmailAccountNameCheck(String emailAccountNameCheck) {
		this.emailAccountNameCheck = emailAccountNameCheck;
	}
	
	public String getEmailAccountNameCheck() {
		return this.emailAccountNameCheck;
	}
	
	public void setEmailHostAddress(String emailHostAddress) {
		this.emailHostAddress = emailHostAddress;
	}
	
	public String getEmailHostAddress() {
		return this.emailHostAddress;
	}
	
	public void setUserRoleName(String role) {
		if (role == null)
			return;
		if (role.equals("Academic")) {
			userRole = new AcademicRegistration();
			this.roleCode = 1;
		} else {
			userRole = new StudentRegistration();
			this.roleCode = 0;
		}
	}
	
	public String getUserRoleName() {
		if (roleCode == 1)
			return "Academic";
		else
			return "Student";
	}
	
	public void changeUserRole(ValueChangeEvent event) {
		if (event != null) {
			String newValue = (String)event.getNewValue();
			setUserRoleName(newValue);
			System.out.println(newValue);
		}
	}
	
	public UserRoleRegistration getUserRole() {
		return this.userRole;
	}
	
	public int getRoleCode() {
		return this.roleCode;
	}
	
}
